home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / tcpech1a / clsperfo.cls < prev    next >
Encoding:
Visual Basic class definition  |  1999-08-25  |  2.5 KB  |  86 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "clsPerformanceMonitor"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
  15. Attribute VB_Ext_KEY = "Collection" ,"Performance"
  16. Attribute VB_Ext_KEY = "Member0" ,"Performance"
  17. Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
  18. Option Explicit
  19.  
  20. 'local variable to hold collection
  21. Private mCol As Collection
  22.  
  23. Public Function Add(PerfName As String, PerfStartTime As Long, PerfEndTime As Long, PerfTotalTime As Long, sKey As String) As Performance
  24.     'create a new object
  25.     Dim objNewMember As Performance
  26.     Set objNewMember = New Performance
  27.  
  28.  
  29.     'set the properties passed into the method
  30.     objNewMember.PerfName = PerfName
  31.     objNewMember.PerfStartTime = PerfStartTime
  32.     objNewMember.PerfEndTime = PerfEndTime
  33.     objNewMember.PerfTotalTime = PerfTotalTime
  34.     mCol.Add objNewMember, sKey
  35.  
  36.  
  37.     'return the object created
  38.     Set Add = objNewMember
  39.     Set objNewMember = Nothing
  40.  
  41.  
  42. End Function
  43.  
  44. Public Function NewEnum() As IUnknown
  45.     Set NewEnum = mCol.[_NewEnum]
  46. End Function
  47.  
  48. Public Function List() As String
  49.     Dim max As Long, i As Long, s As String, l As String
  50.     If Timings = False Then
  51.         List = "Timings are currently off."
  52.         Exit Function
  53.     End If
  54.     max = mCol.Count
  55.     For i = 1 To 40
  56.         l = l & "-"
  57.     Next i
  58.     s = "   " & l & vbCrLf & "Timings as of " & Time & vbCrLf & l & vbCrLf
  59.     For i = 1 To max
  60.         s = s & Left$(Perf(i).PerfName & "                                        ", 40) & vbTab & Format("0.000", Perf(i).PerfTotalTime / 1000) & vbTab & Perf(i).PerfHitCount & vbTab & Format(((Perf(i).PerfTotalTime / Perf(i).PerfHitCount) / 1000), "0.000") & vbCrLf
  61.     Next i
  62.     List = s
  63. End Function
  64.  
  65. Public Property Get Item(vntIndexKey As Variant) As Performance
  66. Attribute Item.VB_UserMemId = 0
  67.   Set Item = mCol(vntIndexKey)
  68. End Property
  69.  
  70. Public Property Get Count() As Long
  71.     Count = mCol.Count
  72. End Property
  73.  
  74. Public Sub Remove(vntIndexKey As Variant)
  75.     mCol.Remove vntIndexKey
  76. End Sub
  77.  
  78. Private Sub Class_Initialize()
  79.     Set mCol = New Collection
  80. End Sub
  81.  
  82. Private Sub Class_Terminate()
  83.     Set mCol = Nothing
  84. End Sub
  85.  
  86.